package models;

import utils.DAOUser;

public class BeanLogin {

	private String user = "";
	private String password = "";
	private int[] error = { 0, 0 };

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public boolean userCorrect() {
		boolean correct = false;
		try {
			DAOUser dao = new DAOUser();
			if (dao.userExists(user)) {
				if (dao.correctPassword(user, password))
					correct = true;
				else
					error[1] = 1;
			} else {
				error[0] = 1;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return correct;
	}

	public int[] getError() {
		return error;
	}

	public void setError(int[] error) {
		this.error = error;
	}

}
